package cn.sofwin.day0107.homework;

import java.util.Scanner;

public class Days {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("输入年份：");
        int year = sc.nextInt();
        System.out.println("输入月份：");
        int month = sc.nextInt();
        int days = day(year, month);
        if (days != 0) {
            System.out.println("这个月有" + days + "天");
        } else {
            System.out.println("月份输入错误");
        }


    }

    static int day(int m, int n) {
        int k = 0;
        switch (n) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                k = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                k = 30;
                break;
            case 2:
                if ((m % 4 == 0) && ((m % 100 != 0) || (m % 400 == 0))) {
                    k = 29;
                } else {
                    k = 28;
                }

                break;


        }
        return k;
    }

}
